namespace OpenRiaServices.Issue92.Web.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitialCreate : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.ChildEntities",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false),
                        ParentEntityId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ParentEntities", t => t.ParentEntityId, cascadeDelete: true)
                .Index(t => t.ParentEntityId);
            
            CreateTable(
                "dbo.ParentEntities",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.ChildEntities", "ParentEntityId", "dbo.ParentEntities");
            DropIndex("dbo.ChildEntities", new[] { "ParentEntityId" });
            DropTable("dbo.ParentEntities");
            DropTable("dbo.ChildEntities");
        }
    }
}
